package model;

import android.content.Context;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.lym.syappandroid.R;

import java.util.List;

/**
 * Created by lym on 2017/6/3.
 */

public class TaskalarmAdapter extends ArrayAdapter<Alarmtask> {
    private int resourceid;

    public TaskalarmAdapter(@NonNull Context context, @LayoutRes int resource, @NonNull List<Alarmtask> objects) {
        super(context, resource, objects);
        resourceid = resource;
    }

    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        Alarmtask alarmtask = getItem(position);
        View view = LayoutInflater.from(getContext()).inflate(resourceid,parent,false);
        ImageView iv_unread = (ImageView)view.findViewById(R.id.iv_alarmtask_unread);
        TextView tv_name = (TextView)view.findViewById(R.id.tv_alarmtask_name);

        if(alarmtask.isT_unread()){
            iv_unread.setImageResource(R.drawable.alarm_unread);
        }else{
            iv_unread.setImageResource(R.drawable.alarm_null);
        }
        tv_name.setText(alarmtask.getT_name());

        return view;
    }
}
